 package com.txby.platformApi.component.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.jck.mybatis.mapper.MybatisBaseDaoCRUD;
import com.txby.pf.common.utils.R;
import com.txby.platformCore.entity.shop.NrsGoods;
import com.txby.platformCore.entity.shop.NrsPerson;
import com.txby.platformCore.entity.shop.OrderMealGoods;
import com.txby.platformCore.entity.shop.ServiceGoods;


@Service
public class WebNrsPersonService {
 
	@Resource(name = "mybatisBaseDaoCRUD")
	public MybatisBaseDaoCRUD mBaseDao;
	/**
	 * 新增普通商品
	 * @param NrsPerson
	 * @return
	 */
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public R saveNrsPerson(NrsPerson goods)  {
		try {
			String sql="select * from "+mBaseDao.tableName(NrsPerson.class)+" where ICNO='"+goods.getICNO()+"'";
			NrsPerson old=(NrsPerson) mBaseDao.findBySqlUniqueObject(sql, NrsPerson.class, null);
			 if(old!=null){
				 return R.ok().error("该商品已存在");
			 }
			 Object savedBG = mBaseDao.saveObject2Object(goods);
			
			System.out.println(savedBG);
		} catch (Exception e) {
			return R.error(5000,e.getMessage());
		}
		return R.ok();
	}

	/** 
	* @Title: updateNrsGoods 
	* @Description:  
	* @param @param nrsGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void updateNrsGoods(NrsGoods nrsGoods) {
		mBaseDao.updateObject(nrsGoods);
	}

	/** 
	* @Title: saveNrsGoods 
	* @Description:  
	* @param @param nrsGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void saveNrsGoods(NrsGoods nrsGoods) {
		mBaseDao.saveObject(nrsGoods);
	}

	/** 
	* @Title: deleteNrsGoods 
	* @Description:  
	* @param @param nrsGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void deleteNrsGoods(NrsGoods nrsGoods) {
		mBaseDao.deleteObject(nrsGoods);
	}

	/** 
	* @Title: updateNrsPerson 
	* @Description:  
	* @param @param NrsPerson    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void updateNrsPerson(NrsPerson NrsPerson) {
		mBaseDao.updateObject(NrsPerson);
		
	}

	/** 
	* @Title: deleteNrsPerson 
	* @Description:  
	* @param @param NrsPerson    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void deleteNrsPerson(NrsPerson NrsPerson) {
		mBaseDao.deleteObject(NrsPerson);
		
	}

	/** 
	* @Title: saveServiceGoods 
	* @Description:  
	* @param @param serviceGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void saveServiceGoods(ServiceGoods serviceGoods) {
		mBaseDao.saveObject(serviceGoods);
		
	}

	/** 
	* @Title: updateServiceGoods 
	* @Description:  
	* @param @param serviceGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void updateServiceGoods(ServiceGoods serviceGoods) {
		mBaseDao.updateObject(serviceGoods);
		
	}

	/** 
	* @Title: deleteServiceGoods 
	* @Description:  
	* @param @param serviceGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void deleteServiceGoods(ServiceGoods serviceGoods) {
		mBaseDao.deleteObject(serviceGoods);
		
	}

	/** 
	* @Title: saveOrderMealGoods 
	* @Description:  
	* @param @param orderMealGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void saveOrderMealGoods(OrderMealGoods orderMealGoods) {
		
		mBaseDao.saveObject(orderMealGoods);
	}

	/** 
	* @Title: updateOrderMealGoods 
	* @Description:  
	* @param @param orderMealGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void updateOrderMealGoods(OrderMealGoods orderMealGoods) {
		mBaseDao.updateObject(orderMealGoods);
		
	}

	/** 
	* @Title: deleteOrderMealGoods 
	* @Description:  
	* @param @param orderMealGoods    设定文件 
	* @return void    返回类型 
	* @throws 
	*/
	@Transactional(propagation = Propagation.REQUIRED,timeout=36000,rollbackFor=Exception.class)
	public void deleteOrderMealGoods(OrderMealGoods orderMealGoods) {
		
		mBaseDao.deleteObject(orderMealGoods);
	}
}
